package com.example.demo.server3;

import com.example.demo.server3.handler.AffairHandler;
import com.example.demo.server3.handler.DecodeHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

public class ServerCmppHandlePipelineInitializer extends ChannelInitializer<SocketChannel> {
/*    private static final int MAX_ALLOW_RESPONSE_LENGTH = 1024 * 1024 * 5;
    private static final int IDLE_READ_SECOND = 3 * 60;
    private static final int IDLE_WRITE_SECOND = 30;*/

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        //日志
        pipeline.addLast(new LoggingHandler(LogLevel.INFO));
        //解码
        //pipeline.addLast(new LengthFieldBasedFrameDecoder(MAX_ALLOW_RESPONSE_LENGTH, 0, 4, -4, 4));
          pipeline.addLast(new DecodeHandler());//这里需要自己实现
        //编码
        //pipeline.addLast(new LengthFieldPrepender(4, true));
       // pipeline.addLast(new HeaderEncoded());//这里需要自己实现
        //协议与数据转换
        //pipeline.addLast(new ProtocolStreamConverter());//这里需要自己实现
        //业务实体
          pipeline.addLast(new AffairHandler());

    }
}
